{{ define "main" }}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>页面局部刷新</title>
  </head>
  <body>
    <h1>load计数</h1>
    <div>{{ template "num" . }}</div>
    <button>局部刷新</button>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script>
      var num = 0;
      $("button").click(function () {
        num++;
        $("div").load(
          "/num",
          {
            num: num,
          },
          function () {
            $.post(
              "/enough",
              {
                num: num,
              },
              function (data, status) {
                if (data === "hide") {
                  $("button").hide();
                }
              }
            );
          }
        );
      });
    </script>
  </body>
</html>
{{ end }}
